```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>同步 异步 阻塞 非阻塞的概念解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background-color: #f8f9fa;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #a777e3 100%);
        }
        .code-block {
            background-color: #2d2d2d;
            color: #f8f8f2;
            border-radius: 8px;
            overflow-x: auto;
        }
        .concept-card {
            transition: all 0.3s ease;
            border-radius: 12px;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
        }
        .concept-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .pros-cons-icon {
            font-size: 1.5rem;
            margin-right: 0.5rem;
        }
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 0.65;
            margin: 0.1em 0.2em 0 0;
            color: #6e8efb;
            font-weight: 700;
        }
        .section-icon {
            font-size: 2rem;
            color: #6e8efb;
            margin-bottom: 1rem;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-5xl mx-auto text-center">
            <h1 class="text-4xl md:text-5xl lg:text-6xl font-bold mb-6 leading-tight">
                同步 vs 异步 vs 阻塞 vs 非阻塞
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto mb-10">
                深入理解现代编程中的核心并发概念
            </p>
            <div class="bg-white bg-opacity-20 rounded-lg p-6 max-w-4xl mx-auto">
                <p class="text-lg md:text-xl italic drop-cap">
                    我们每天使用的许多应用程序和服务，无论是浏览网页、在线购物，还是视频流播放，都依赖于这些概念的正确应用。掌握它们可以让你编写出更高效的代码，提升系统的性能，并且在面对复杂的并发和多线程问题时，做出更明智的设计决策。
                </p>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Introduction -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">概念总览</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="bg-white p-8 rounded-xl concept-card">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-exchange-alt section-icon"></i>
                        <h3 class="text-2xl font-semibold ml-3">同步 vs 异步</h3>
                    </div>
                    <div class="space-y-4">
                        <p><span class="font-bold">同步</span>：任务按顺序执行，每个任务必须等待前一个任务完成</p>
                        <p><span class="font-bold">异步</span>：任务可以并发执行，不需要等待其他任务完成</p>
                    </div>
                </div>
                <div class="bg-white p-8 rounded-xl concept-card">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-pause-circle section-icon"></i>
                        <h3 class="text-2xl font-semibold ml-3">阻塞 vs 非阻塞</h3>
                    </div>
                    <div class="space-y-4">
                        <p><span class="font-bold">阻塞</span>：线程会暂停执行，等待条件满足</p>
                        <p><span class="font-bold">非阻塞</span>：线程不会暂停，立即返回并继续执行</p>
                    </div>
                </div>
            </div>

            <!-- Visualization -->
            <div class="bg-white p-6 rounded-xl shadow-lg">
                <div id="mermaid-diagram" class="mermaid">
                    graph TD
                        A[编程模型] --> B[同步/异步]
                        A --> C[阻塞/非阻塞]
                        B --> D[同步: 任务顺序执行]
                        B --> E[异步: 任务并发执行]
                        C --> F[阻塞: 线程暂停等待]
                        C --> G[非阻塞: 线程继续执行]
                </div>
            </div>
        </section>

        <!-- Synchronous Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">同步（Synchronous）</h2>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-lg mb-8 concept-card">
                <div class="flex items-center mb-4">
                    <i class="fas fa-sync-alt section-icon"></i>
                    <h3 class="text-2xl font-semibold ml-3">工作原理</h3>
                </div>
                <p class="mb-4">同步操作通常通过线程阻塞的方式实现。在进行同步操作时，线程会一直等待操作完成，不会执行其他任务。</p>
                <p>例如，进行一个同步的文件读写操作时，线程会一直等待文件操作完成，直到读取或写入结束，线程才会继续执行后续的任务。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-green-500 pros-cons-icon"></i>
                        优点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>简单性：同步操作通常比异步操作更容易理解和实现</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>数据一致性：确保多个线程访问共享资源时的数据一致性</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>调试方便：执行顺序是可预见的，调试和测试更为方便</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-exclamation-circle text-red-500 pros-cons-icon"></i>
                        缺点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>性能瓶颈：线程阻塞会导致性能问题</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>资源浪费：等待时依然占用系统资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>扩展性差：不易于实现高性能、高可用的系统架构</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg mb-8 concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-code section-icon"></i>
                    <span class="ml-2">代码示例</span>
                </h3>
                <div class="code-block p-4 rounded-lg">
                    <pre><code class="language-java">public class SynchronizedCounter {
    private int count = 0;

    // 同步方法，保证线程安全
    public synchronized void increment() {
        count++;
    }

    // 同步方法，保证线程安全
    public synchronized int getCount() {
        return count;
    }

    public static void main(String[] args) {
        SynchronizedCounter counter = new SynchronizedCounter();

        // 创建多个线程同时操作 counter
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                counter.increment();
            }
        });

        Thread t2 = new Thread(() -> {
            for (int i = 0; i < 1000; i++) {
                counter.increment();
            }
        });

        t1.start();
        t2.start();

        // 等待线程执行完毕
        try {
            t1.join();
            t2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        // 输出最终的计数值
        System.out.println("Final count is: " + counter.getCount());
    }
}</code></pre>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-tasks section-icon"></i>
                    <span class="ml-2">实际应用</span>
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-700 mb-2">线程同步</h4>
                        <p>在多线程编程中，线程同步确保多个线程在访问共享资源时不会产生竞争条件。</p>
                    </div>
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-700 mb-2">数据库事务</h4>
                        <p>事务的同步处理确保一组操作要么全部完成，要么全部不执行。</p>
                    </div>
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-700 mb-2">I/O 操作</h4>
                        <p>同步 I/O 操作在读取文件或从网络获取数据时，程序会等待操作完成。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Asynchronous Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-purple-500 mr-4"></div>
                <h2 class="text-3xl font-bold">异步（Asynchronous）</h2>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-lg mb-8 concept-card">
                <div class="flex items-center mb-4">
                    <i class="fas fa-random section-icon"></i>
                    <h3 class="text-2xl font-semibold ml-3">工作原理</h3>
                </div>
                <p class="mb-4">异步操作通常通过事件驱动的方式实现。在执行异步操作时，任务会被提交到任务队列，主线程继续执行其他任务。</p>
                <p>当异步操作完成后，任务队列会通知主线程，并调用相应的回调函数或者通过 Future 和 Promise 等机制处理结果。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-green-500 pros-cons-icon"></i>
                        优点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>高效利用系统资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>提升系统性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>用户体验友好</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-exclamation-circle text-red-500 pros-cons-icon"></i>
                        缺点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>复杂性增加</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>调试困难</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>潜在的线程安全问题</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg mb-8 concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-code section-icon"></i>
                    <span class="ml-2">代码示例</span>
                </h3>
                <div class="code-block p-4 rounded-lg">
                    <pre><code class="language-java">import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class AsyncDemo {
    public static void main(String[] args) {
        // 异步执行任务
        CompletableFuture&lt;String&gt; future = CompletableFuture.supplyAsync(() -> {
            try {
                // 模拟耗时操作
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return "Hello, World!";
        });

        // 继续执行其他任务
        System.out.println("Continuing with other tasks...");

        // 等待异步任务完成并获取结果
        try {
            String result = future.get();
            System.out.println("Async task result: " + result);
        } catch (InterruptedException | ExecutionException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-project-diagram section-icon"></i>
                    <span class="ml-2">异步编程模型</span>
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-700 mb-2">回调（Callback）</h4>
                        <p>异步操作完成后，通过回调函数处理结果。</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-700 mb-2">Future 和 Promise</h4>
                        <p>在任务完成后获取结果，避免回调地狱的问题。</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-purple-700 mb-2">Reactive Programming</h4>
                        <p>通过流和数据流操作符处理异步数据流。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Blocking Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-orange-500 mr-4"></div>
                <h2 class="text-3xl font-bold">阻塞（Blocking）</h2>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-lg mb-8 concept-card">
                <div class="flex items-center mb-4">
                    <i class="fas fa-pause section-icon"></i>
                    <h3 class="text-2xl font-semibold ml-3">工作原理</h3>
                </div>
                <p class="mb-4">在阻塞操作中，线程会主动让出CPU的使用权，进入等待状态。当阻塞条件满足时，线程会被唤醒，重新获得CPU使用权，继续执行。</p>
                <p>阻塞操作通常用于等待某些事件的发生，如I/O操作完成、获取锁资源、等待网络数据等。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-green-500 pros-cons-icon"></i>
                        优点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>逻辑简单</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>可靠性高</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>线程管理方便</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-exclamation-circle text-red-500 pros-cons-icon"></i>
                        缺点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>性能瓶颈</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>资源浪费</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>扩展性差</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg mb-8 concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-code section-icon"></i>
                    <span class="ml-2">代码示例</span>
                </h3>
                <div class="code-block p-4 rounded-lg">
                    <pre><code class="language-java">import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

public class BlockingIODemo {
    public static void main(String[] args) {
        try (BufferedReader reader = new BufferedReader(new FileReader("example.txt"))) {
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}</code></pre>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-layer-group section-icon"></i>
                    <span class="ml-2">阻塞操作种类</span>
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-orange-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-orange-700 mb-2">输入输出阻塞</h4>
                        <p>等待I/O操作完成，例如文件读写、网络数据传输等。</p>
                    </div>
                    <div class="bg-orange-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-orange-700 mb-2">锁阻塞</h4>
                        <p>等待锁资源可用，在多线程编程中常见。</p>
                    </div>
                    <div class="bg-orange-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-orange-700 mb-2">条件变量阻塞</h4>
                        <p>等待特定条件满足，如生产者-消费者模型。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Non-blocking Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-green-500 mr-4"></div>
                <h2 class="text-3xl font-bold">非阻塞（Non-blocking）</h2>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-lg mb-8 concept-card">
                <div class="flex items-center mb-4">
                    <i class="fas fa-forward section-icon"></i>
                    <h3 class="text-2xl font-semibold ml-3">工作原理</h3>
                </div>
                <p class="mb-4">在非阻塞操作中，当一个线程尝试执行某个操作时，如果条件不满足，它会立即返回一个状态值或抛出一个异常，表示操作未成功。</p>
                <p>线程可以根据返回的状态值决定下一步的操作，而不会进入等待状态。这种机制允许线程在等待资源的同时继续执行其他任务。</p>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-8">
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-check-circle text-green-500 pros-cons-icon"></i>
                        优点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>高效利用CPU资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>提升系统并发性能</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span>减少线程竞争</span>
                        </li>
                    </ul>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                    <h3 class="text-xl font-semibold mb-4 flex items-center">
                        <i class="fas fa-exclamation-circle text-red-500 pros-cons-icon"></i>
                        缺点
                    </h3>
                    <ul class="space-y-2">
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>实现复杂</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>调试困难</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span>潜在的资源浪费</span>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg mb-8 concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-code section-icon"></i>
                    <span class="ml-2">代码示例</span>
                </h3>
                <div class="code-block p-4 rounded-lg">
                    <pre><code class="language-java">import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;

public class NonBlockingIODemo {
    public static void main(String[] args) throws IOException {
        Selector selector = Selector.open();
        ServerSocketChannel serverSocket = ServerSocketChannel.open();
        serverSocket.bind(new InetSocketAddress("localhost", 8080));
        serverSocket.configureBlocking(false);
        serverSocket.register(selector, SelectionKey.OP_ACCEPT);

        while (true) {
            selector.select();
            Iterator&lt;SelectionKey&gt; keys = selector.selectedKeys().iterator();
            while (keys.hasNext()) {
                SelectionKey key = keys.next();
                keys.remove();

                if (key.isAcceptable()) {
                    SocketChannel client = serverSocket.accept();
                    client.configureBlocking(false);
                    client.register(selector, SelectionKey.OP_READ);
                } else if (key.isReadable()) {
                    SocketChannel client = (SocketChannel) key.channel();
                    ByteBuffer buffer = ByteBuffer.allocate(256);
                    int bytesRead = client.read(buffer);
                    if (bytesRead > 0) {
                        buffer.flip();
                        byte[] data = new byte[buffer.remaining()];
                        buffer.get(data);
                        System.out.println(new String(data));
                    } else if (bytesRead == -1) {
                        client.close();
                    }
                }
            }
        }
    }
}</code></pre>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-sitemap section-icon"></i>
                    <span class="ml-2">非阻塞编程模型</span>
                </h3>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-green-700 mb-2">轮询（Polling）</h4>
                        <p>线程不断检查资源的状态，如果资源可用则执行相应操作。</p>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-green-700 mb-2">事件驱动</h4>
                        <p>通过事件循环和回调机制处理异步事件。</p>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-green-700 mb-2">无锁数据结构</h4>
                        <p>使用CAS操作实现无锁数据结构，避免线程竞争。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Comparison Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-16 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold">区别与联系</h2>
            </div>
            
            <div class="bg-white p-8 rounded-xl shadow-lg mb-8 concept-card">
                <div class="flex items-center mb-4">
                    <i class="fas fa-utensils section-icon"></i>
                    <h3 class="text-2xl font-semibold ml-3">厨房比喻</h3>
                </div>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-semibold text-indigo-700 mb-3">同步阻塞</h4>
                        <p>你在切菜（同步操作），必须等所有的菜都切完才能开始炒菜。如果在切菜过程中，你发现刀不够锋利，你必须停下来磨刀（等待条件满足），直到刀锋利了才能继续切菜。</p>
                    </div>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-semibold text-indigo-700 mb-3">同步非阻塞</h4>
                        <p>你在切菜（同步操作），如果发现刀不够锋利，你不必停下来磨刀，而是可以立即换一把备用的锋利刀（不会等待，继续执行任务）。</p>
                    </div>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-semibold text-indigo-700 mb-3">异步阻塞</h4>
                        <p>你一边切菜（异步操作），一边烤肉。如果烤肉炉突然熄火（条件不满足），你必须停下来（阻塞）修理烤肉炉，直到烤肉炉重新点燃，才能继续切菜和烤肉。</p>
                    </div>
                    <div class="bg-indigo-50 p-6 rounded-lg">
                        <h4 class="font-semibold text-indigo-700 mb-3">异步非阻塞</h4>
                        <p>你一边切菜（异步操作），一边烤肉。如果烤肉炉突然熄火（条件不满足），你可以立即通知助手（线程）去修理烤肉炉，而你继续切菜。烤肉炉修好后，助手会通知你（条件满足后通知），你可以继续烤肉。</p>
                    </div>
                </div>
            </div>

            <div class="bg-white p-6 rounded-xl shadow-lg concept-card">
                <h3 class="text-xl font-semibold mb-4 flex items-center">
                    <i class="fas fa-arrows-alt-h section-icon"></i>
                    <span class="ml-2">关键区别</span>
                </h3>
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="border-l-4 border-blue-500 pl-4 py-2">
                        <h4 class="font-bold text-lg mb-2">同步与异步的区别</h4>
                        <p>同步需要等待当前任务完成才能开始下一个任务，而异步可以同时进行多个任务。</p>
                    </div>
                    <div class="border-l-4 border-green-500 pl-4 py-2">
                        <h4 class="font-bold text-lg mb-2">阻塞与非阻塞的区别</h4>
                        <p>阻塞在条件不满足时暂停任务，等待条件满足后继续执行，而非阻塞在条件不满足时继续执行其他任务，不会暂停。</p>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
    </script>
</body>
</html>
```